//
//  KABMyShopHeaderCRView.m
//  kabu
//
//  Created by XiangDongMBP on 2017/3/9.
//  Copyright © 2017年 East. All rights reserved.
//

#import "KABMyShopHeaderCRView.h"
#import "UIColor+XDHex.h"
#import "KABModel.h"
#import <YYWebImage.h>

@implementation KABMyShopHeaderCRView

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    
    self.portraitImgView.layer.masksToBounds = YES;
    self.portraitImgView.layer.cornerRadius = CGRectGetWidth(self.portraitImgView.bounds) / 2.0;
    self.portraitImgView.layer.borderWidth = 3;
    self.portraitImgView.layer.borderColor = [UIColor xd_colorWithHex:0xF0F0F0].CGColor;
    
    self.portraitImgView.userInteractionEnabled = YES;
    UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(portraitImgViewTapped:)];
    [self.portraitImgView addGestureRecognizer:tapGesture];
    
    self.phoneBtn.userInteractionEnabled = NO;
}

- (void)portraitImgViewTapped:(UIGestureRecognizer *)gesture {
    if ([self.delegate respondsToSelector:@selector(kABMyShopHeaderCRView:portraitTapped:)]) {
        [self.delegate kABMyShopHeaderCRView:self portraitTapped:(UIImageView *)gesture.view];
    }
}

- (void)configViewWithShopDetInfo:(KABMallShopDetInfo *)shopInfo {
    [self.bgImgView yy_setImageWithURL:[NSURL URLWithString:shopInfo.shop_background_url]
                           placeholder:[KABDefaultVarModel sharedInstance].bigDefaultImg
                               options:YYWebImageOptionSetImageWithFadeAnimation
                            completion:nil];
    [self.portraitImgView yy_setImageWithURL:[NSURL URLWithString:shopInfo.shop_head_imgurl]
                                 placeholder:[KABDefaultVarModel sharedInstance].smallDefaultImg
                                     options:YYWebImageOptionSetImageWithFadeAnimation
                                  completion:nil];
    self.nameLabel.text = shopInfo.shop_owner_name;
    NSString *phoneStr = [NSString stringWithFormat:@"  %@", shopInfo.shop_owner_phone_number];
    [self.phoneBtn setTitle:phoneStr forState:UIControlStateNormal];
    self.phoneBtn.hidden = YES;
}

@end
